import axios from 'axios';


/*聚合数据短信接口  */
export const juheSengCodeApi = async (phone: string, code: string) => {

    const params = new URLSearchParams();

    params.append('mobile', phone);
    params.append('tplId', process.env.SMSID || '66273');
    params.append('key', '46b5d3847f05f6cc0d98cb3307e0ac94');
    params.append('tplValue', `#code#=${code}`);

    try {

        const sengCode = await axios.post('https://v.juhe.cn/vercodesms/send.php', params);
        if (sengCode.data.error_code == 0) {
            return {
                code: 200,
                phone,
                msg: '发送验证码成功'
            };
        };

        return sengCode.data;

    } catch (error) { throw error };

}